package com.biz.primus.ms.member.dao.redis;

import com.biz.primus.base.redis.CrudRedisDao;
import com.biz.primus.ms.member.dao.ro.MemberSecretQuestionRo;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * @author jun.liu
 * @date 2017年10月23日
 * @reviewer
 * @see
 */
@Repository
public class MemberSecretQuestionRedisDao extends CrudRedisDao<MemberSecretQuestionRo, Long>
{
    private String getMemberSecretQuestionOnMemberIdMappingKey(Long memberId)
    {
        return getKeyByParams("memberId", memberId);
    }

    public List<MemberSecretQuestionRo> findByMemberId(Long memberId)
    {
        String key = getMemberSecretQuestionOnMemberIdMappingKey(memberId);
        Set<byte[]> bytes = zRange(key, 0, -1);
        return findByIds(bytes);
    }
}
